﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Net.Mail;

namespace OnlineOrderSystem
{
    public partial class ContactUs : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            string name = tb_Name.Text;
            string email = tb_Email.Text;
            string comment = ta_Comment.InnerText;
            string rating = "";
            if (ddl_Rating.SelectedValue == "1")
            {
                rating = "Excellent";
            }
            else if (ddl_Rating.SelectedValue == "2")
            {
                rating = "Good";
            }
            else if (ddl_Rating.SelectedValue == "3")
            {
                rating = "Average";
            }
            else if (ddl_Rating.SelectedValue == "4")
            {
                rating = "Not So Great";
            }
            else if (ddl_Rating.SelectedValue == "5")
            {
                rating = "Need Big Improvement";
            }

            NetworkCredential cred = new NetworkCredential("feedbackcollection2013@gmail.com", "!1qaz@2wsx");/////..........................
            MailMessage msg = new MailMessage();
            msg.To.Add("liuwei7923bupt@gmail.com");
            msg.From = new MailAddress("feedbackcollection2013@gmail.com");
            msg.Subject = "Comment from: " + name;
            msg.Body = "Name: " + name + "\n\nEmail: " + email + "\n\nRating: " + rating + "\n\nComment: " + comment;
            SmtpClient client = new SmtpClient("smtp.gmail.com", 25);

            client.Credentials = cred; 
            client.EnableSsl = true;   
            client.Send(msg);

            tb_Name.Text = "";
            tb_Email.Text = "";
            ddl_Rating.SelectedValue = "1";
            ta_Comment.InnerText = "";


        }
    }
}